//
//  DeviceModel.m
//  Fantasia
//
//  Created by kongkong on 2016/11/1.
//  Copyright © 2016年 Kongkong. All rights reserved.
//

#import "DeviceModel.h"

@implementation DeviceModel

+ (DeviceModel*)modelWithData:(NSDictionary*)data{
    DeviceModel *device = [[DeviceModel alloc]init];
    device.deviceId = data[@"id"];
    device.deviceName = data[@"name"];
    device.deviceType = data[@"type"];
    device.active = [data[@"active"]integerValue] > 0;
    return device;
}

- (NSString*)name4Show{
    if (EMPTY_STR(self.deviceName)) {
        return self.deviceId;
    }
    
    return [NSString stringWithFormat:@"%@(%@)",self.deviceName,self.deviceId];
}
@end
